package com.sun.memo.config;

import javax.persistence.AttributeConverter;

/**
 * 自定义转换器
 * jdbcType(int) - > javaType(boolean)
 * 1 - > true ; 0 - > false
 */
public class StateAttributeConverter implements AttributeConverter<Boolean,Integer> {
    @Override
    public Integer convertToDatabaseColumn(Boolean aBoolean) {

        return aBoolean ?1:0;
    }

    @Override
    public Boolean convertToEntityAttribute(Integer integer) {
        return integer == 1;
    }
}
